'use strict';

import * as actions from '../../actions/index';

// 对页面prop 数据进行管理
const initialState = {
  loading: false,
  error:false,
  loginError:false,
  message:"",
  curActive:false,
  selectedTopics:[]
};
const defaultAction = {
  type: 'doNothing'
}; 
export default function index(state = initialState, action = defaultAction) {
      switch (action.type) {
		case actions.LOAD_START:
			return Object.assign({}, state, {
				loading:true,
				error:false,
				loginError:false
			});
		break;
		case actions.LOAD_ERR:
			return Object.assign({}, state, {
				loading:false,
				error:true,
				loginError:action.loginFalse,
				message:action.message
			});
		break;
		case actions.CLOSE_DIALOG:
			return Object.assign({}, state, {
				error:action.visible,
				loginError:false,
				showTmcDialog:false,
				tmcStatus:action.tmcStatus
			});
		break;
		case actions.GET_STATUS:
			return Object.assign({}, state, {
				loading:false,
				error:false,
				loginError:false,
				tmcStatus:action.tmcStatus
			});
		break;
		case actions.GET_TMC_DATA:
			return Object.assign({}, state, {
				loading:false,
				error:false,
				showTmcDialog:true,
				tmc_user:action.data,
				topics:action.topics,
				selectedTopics:action.selectedTopics
			});
		break;
		default:
		return state;
	}
}
